package com.smbms.utils;

/**
 * @Description 描述
 * @Author 羽落陌殇
 * @Date 2021/7/19 15:52
 * @Version 1.0.0
 */
public class PageSupport {
    // 当前页码 - 来自于用户前端输入 默认值为 1
    private int currentPageNo = 1;
    // 总数量 (来自于数据查询)
    private int totalCount = 0;
    // 页面容量
    private int pageSize = 0;
    // 总页数 - totalCount / pageSize
    private int totalPageCount = 1;

    public int getCurrentPageNo() {
        return currentPageNo;
    }

    public void setCurrentPageNo(int currentPageNo) {
        if (currentPageNo > 0) {
            this.currentPageNo = currentPageNo;
        }
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        if (totalCount > 0) {
            this.totalCount = totalCount;
            // 设置总页数
            this.setTotalPageCountRs();
        }
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        if (pageSize > 0) {
            this.pageSize = pageSize;
        }
    }

    public int getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(int totalPageCount) {
        this.totalPageCount = totalPageCount;
    }

    // 设置总页数方法
    public void setTotalPageCountRs() {
        if (this.totalCount % this.pageSize == 0) {
            this.totalPageCount = this.totalCount / this.pageSize;
        } else if (this.totalCount % this.pageSize > 0) {
            this.totalPageCount = this.totalCount / this.pageSize + 1;
        } else {
            this.totalPageCount = 0;
        }
    }
}
